home *** CD-ROM | disk | FTP | other *** search
- /* Save a copy of a string. */
-
- #include "configure.h"
-
- #ifdef LSC
-
- /* Function prototypes */
-
- #include <proto.h>
- char *strdup(char *str);
- char *strndup(char *str, int n);
-
- #else
-
-
- #ifdef __STDC__
- #include <stddef.h>
- #include <string.h>
- #include <memory.h>
-
- #ifndef NULL
- #define NULL ((void *)0)
- #endif
- void *malloc(size_t);
- char *strcpy(char *, const char *), *strncpy(char *, const char *, size_t);
- #else
- #define NULL 0
- char *malloc(), *strcpy(), *strncpy();
- #endif
-
- #endif
-
- #if !defined(atarist) && !defined(__GNUC__)
- char *
- strdup(str)
- #ifdef __STDC__
- const
- #endif
- char *str;
- {
- char *copy= NULL;
-
- if (str != NULL) {
- copy= malloc((size_t) (strlen(str) + 1));
- if (copy != NULL)
- strcpy(copy, str);
- }
- return copy;
- }
- #endif
-
- char *
- strndup(str, len)
- char *str;
- int len;
- {
- char *copy= NULL;
-
- if (str != NULL) {
- copy= malloc((size_t) (len + 1));
- if (copy != NULL) {
- strncpy(copy, str, (size_t)len);
- copy[len]= '\0';
- }
- }
- return copy;
- }
-